package com.buba.system.service.impl;

import com.buba.system.pojo.Employee;
import com.buba.system.service.EmployeeService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

@Service("employeeServiceImpl")
public class EmployeeServiceImpl implements EmployeeService {
    @DubboReference
    private EmployeeService employeeMapper;

    @Override
    public Employee selEmployee(String employeeId) {
        return employeeMapper.selEmployee(employeeId);
    }

    @Override
    public long selEmpCount(Map<String, Object> map) {
        return employeeMapper.selEmpCount(map);
    }

    @Override
    public List<Employee> selEmp(Map<String, Object> map) {
        return employeeMapper.selEmp(map);
    }

    @Override
    public List<Employee> selEmpTitle(String employeeId) {
        return employeeMapper.selEmpTitle(employeeId);
    }
    /**
     * 去除重复数据
     * @param
     * @return
     */
    @Override
    public List<Employee> noDup(List<Employee> empList) {
        Set<Employee> set = new TreeSet<>();
        for (Employee employee: empList) {
            set.add(employee);
        }
        empList.clear();
        for (Employee employee:set) {
            empList.add(employee);
        }
        return empList;
    }

    @Override
    public Integer addEmp(Employee employee) {
        return employeeMapper.addEmp(employee);
    }

    @Override
    public Integer addEmpjob(Map<String, Object> map) {
        return employeeMapper.addEmpjob(map);
    }

    @Override
    public Integer delEmp(String employeeId) {
        return employeeMapper.delEmp(employeeId);
    }

    @Override
    public Integer delEmpAll(List<String> list) {
        return employeeMapper.delEmpAll(list);
    }

    @Override
    public Integer updEmp(Map<String, Object> map) {
        return employeeMapper.updEmp(map);
    }
}
